package org.come.control;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import org.come.Frame.ZhuFrame;
import org.come.action.NpcMenuAction;
import org.come.bean.SuitOperBean;
import org.come.entity.Goodstable;
import org.come.entity.PartJade;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.starcard.JframeStarCardMain;
import org.come.starcard.JpanelStarCardMain;
import org.come.until.GoodsListFromServerUntil;
import org.come.until.GsonUtil;

import com.tool.role.RoleData;

public class StarCardSupplement implements NpcMenuAction {

	@Override
	public void menuControl(String type) {
		JpanelStarCardMain jpanelStarCardMain = JframeStarCardMain.getJframeSummonEquipMain().getJpanelStarCardMain();
		BigDecimal chooseStarCardId = jpanelStarCardMain.getChooseStarCardId();
		if (chooseStarCardId == null) {
			ZhuFrame.getZhuJpanel().addPrompt2("请选择要补充的星卡");
			return;
		}
		Goodstable goodstable = GoodsListFromServerUntil.getRgid(chooseStarCardId);
		if (goodstable == null) {
			ZhuFrame.getZhuJpanel().addPrompt2("请选择要补充的星卡");
			return;
		}
		SuitOperBean suitOperBean = new SuitOperBean();
		List<BigDecimal> goods = new ArrayList<>();
		goods.add(chooseStarCardId);
		suitOperBean.setType(59);
		PartJade jade = null;
		suitOperBean.setGoods(goods);
		if ("星芒恢复(100点=1000点战力)".equals(type)) {
			if (RoleData.getRoleData().getLoginResult().getScoretype("星芒").compareTo(new BigDecimal(100)) < 0) {
				ZhuFrame.getZhuJpanel().addPrompt2("星芒不足");
				return;
			}
			jade = new PartJade(1, 0);
		} else if ("金币恢复(1000万=1000点战力)".equals(type)) {
			if (RoleData.getRoleData().getLoginResult().getGold().compareTo(new BigDecimal(10000000)) < 0) {
				ZhuFrame.getZhuJpanel().addPrompt2("大话币不足");
				return;
			}
			jade = new PartJade(0, 0);
		}
		if (jade == null) {
			return;
		}
		suitOperBean.setJade(jade);
		String sendmes = Agreement.suitOperateAgreement(GsonUtil.getGsonUtil().getgson().toJson(suitOperBean));
		SendMessageUntil.toServer(sendmes);
	}
}
